package com.ittable.datasource.route.dynamicdatasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * 动态数据源路由
 *
 * @author srh
 * @date 2020/12/20
 **/
public class DynamicDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        DynamicDataSourceTypeEnum dataSourceType = DynamicDataSourceContextHolder.getDataSourceType();
        System.out.println("in@DynamicDataSource#determineCurrentLookupKey datasourceType=" + dataSourceType);
        return dataSourceType == null ? null : dataSourceType.getCode();
    }

}
